Skip to content

fix(oxfmt): Skip vite.config.ts w/o .fmt field in auto-discovery#20254

Merged
graphite-app[bot] merged 1 commit intomainfrom
03-12-fix_oxfmt_skip_vite.config.ts_w_o_.fmt_field_in_auto-discovery
Mar 12, 2026
Merged

fix(oxfmt): Skip vite.config.ts w/o .fmt field in auto-discovery#20254
graphite-app[bot] merged 1 commit intomainfrom
03-12-fix_oxfmt_skip_vite.config.ts_w_o_.fmt_field_in_auto-discovery

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented Mar 12, 2026

Fixes #20237

Copilot AI review requested due to automatic review settings March 12, 2026 02:40
Copy link
Member Author

leaysgur commented Mar 12, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts oxfmt config auto-discovery so that vite.config.ts is only treated as an Oxfmt config when it contains the expected .fmt field, while keeping explicit --config vite.config.ts strict (erroring if .fmt is missing).

Changes:

  • Split explicit config loading vs upward auto-discovery, and add “skip vite.config.ts without .fmt” behavior during auto-discovery.
  • Plumb config_dir (not “config path”) into the walker so ignorePatterns resolve relative to the loaded config directory.
  • Extend CLI snapshot tests/fixtures to cover explicit-error vs auto-discovery-skip behavior (including “skip child vite config, find parent config”).

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
apps/oxfmt/src/core/config.rs Implements explicit-load vs auto-discovery; skips vite.config.ts without .fmt; adds config_dir() accessor.
apps/oxfmt/src/cli/format.rs Switches to ConfigResolver::from_config for discovery; uses config_dir() for ignorePatterns and “no config” hint logic.
apps/oxfmt/src/cli/walk.rs Changes ignorePatterns root from config file path to config_dir.
apps/oxfmt/src/stdin/mod.rs Routes --config directly into ConfigResolver::from_config (no separate path resolver).
apps/oxfmt/src/lsp/server_formatter.rs Removes resolve_oxfmtrc_path usage; passes optional config path directly to ConfigResolver::from_config.
apps/oxfmt/src/core/mod.rs Stops exporting the removed resolve_oxfmtrc_path.
apps/oxfmt/test/cli/vite_config/vite_config.test.ts Adds test cases for explicit --config error vs auto-discovery skip behavior.
apps/oxfmt/test/cli/vite_config/snapshots/vite_config.test.ts.snap Updates/adds snapshots for the new CLI behaviors.
apps/oxfmt/test/cli/vite_config/fixtures/skip_finds_parent/** Adds fixtures to validate skipping child vite.config.ts and finding a parent .oxfmtrc.json.

You can also share your feedback on Copilot code review. Take the survey.

@leaysgur leaysgur changed the title fix(oxfmt): Skip vite.config.ts w/o .fmt field in auto-discovery fix(oxfmt): Skip vite.config.ts w/o .fmt field in auto-discovery Mar 12, 2026
@leaysgur leaysgur force-pushed the 03-12-fix_oxfmt_skip_vite.config.ts_w_o_.fmt_field_in_auto-discovery branch from 2308d45 to 079cd61 Compare March 12, 2026 02:52
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Mar 12, 2026
@graphite-app
Copy link
Contributor

graphite-app bot commented Mar 12, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the 03-12-fix_oxfmt_skip_vite.config.ts_w_o_.fmt_field_in_auto-discovery branch from 079cd61 to 11a2b45 Compare March 12, 2026 04:14
graphite-app bot pushed a commit that referenced this pull request Mar 12, 2026
#20255)

The same as #20254 for Oxlint.

The refactoring to move the logic to the JS side is being addressed in a subsequent PR. (Copilot review will be also addressed)
@graphite-app graphite-app bot merged commit 11a2b45 into main Mar 12, 2026
19 checks passed
@graphite-app graphite-app bot deleted the 03-12-fix_oxfmt_skip_vite.config.ts_w_o_.fmt_field_in_auto-discovery branch March 12, 2026 04:25
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 12, 2026
leaysgur added a commit that referenced this pull request Mar 12, 2026
# Oxlint
### 🐛 Bug Fixes

- 4ea67de oxlint,oxfmt: Skip `vite.config.ts` exports `defineConfig(fn)`
(#20260) (leaysgur)
- cc89dbf oxlint: Skip `vite.config.ts` w/o `.lint` field in
auto-discovery (#20255) (leaysgur)
- 89b7ca9 linter/no-duplicate-imports: Only check aggregated exports
(#20178) (kennytm)
- 691f556 linter/explicit-module-boundary-types: Ignore constructor
callbacks (#20221) (camc314)

### ⚡ Performance

- d160dca linter/plugins: Reduce array lookups in visitor compilation
(#20249) (overlookmotel)

### 📚 Documentation

- 0c7da4f linter: Fix extra closing brace in example config. (#20253)
(connorshea)
- 13606c3 linter/plugins: Update conformance README (#20234)
(overlookmotel)
# Oxfmt
### 🐛 Bug Fixes

- 4ea67de oxlint,oxfmt: Skip `vite.config.ts` exports `defineConfig(fn)`
(#20260) (leaysgur)
- 11a2b45 oxfmt: Skip `vite.config.ts` w/o `.fmt` field in
auto-discovery (#20254) (leaysgur)

Co-authored-by: leaysgur <6259812+leaysgur@users.noreply.github.com>
@jamesbvaughan
Copy link

I believe I'm still hitting the issue that this was meant to solve with oxfmt v0.40.0.

❯ yarn client format:oxfmt
Failed to load configuration file.
/Users/james/code/project/apps/client/vite.config.ts
Ensure the file has a valid default export of a JSON-serializable configuration object.

This is in a monorepo with a root-level .oxfmtrc.jsonc and no fmt field in the file referenced in that error.

Let me know if it would be helpful to put together a minimal reproduction.

@camc314
Copy link
Contributor

camc314 commented Mar 13, 2026

can you sure your vite config @jamesbvaughan

@jamesbvaughan
Copy link

I've spent some time trying to narrow down the issue and found that the content of vite.config.ts is irrelevant for the specific way I'm hitting the error. The file can be completely empty and it doesn't change the result.

I believe I've narrowed the problem down to something involving either Volta or differences in Node versions.

I have a minimal repro in a repo with this structure:

.
├── apps
│   └── client
│       ├── package.json
│       └── vite.config.ts
├── package.json
└── yarn.lock

Where the root package.json is:

{
  "name": "oxfmt-issue-demo",
  "workspaces": {
    "packages": [
      "apps/*"
    ]
  },
  "type": "module",
  "devDependencies": {
    "oxfmt": "^0.40.0"
  },
  "volta": {
    "node": "22.16.0"
  },
  "packageManager": "yarn@4.13.0"
}

It doesn't matter what's in vite.config.ts. If I change the node version specified in that root package.json from 22.16.0 to 22.20.0, the issue goes away and I can run yarn workspace client oxfmt without issue.

@jamesbvaughan
Copy link

Actually it seems that this will be fixed in the next release for me. The change in this PR fixed my issue: #20326

@miyaoka miyaoka mentioned this pull request Mar 14, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-formatter Area - Formatter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formatter: LSP falls back to wrong oxfmt config when in workspace

4 participants